/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.tigris.jasmincc.framework;

import java.util.Map;

/**
 * This class manages the renaming of tokens and methods.
 * 
 * @author Sam Huang
 * 
 */
public interface NamingManager {
	/**
	 * Add a new declaration(method) to this grammar.
	 * 
	 * @param name
	 */
	void addDeclaration(String name);

	/**
	 * Add a new instance to this grammar.
	 * 
	 * @param name
	 * @param qualifiedName
	 */
	void addInstance(String name, String qualifiedName);

	/**
	 * Check if the grammarName equals to the instanceName.
	 * 
	 * @param grammarName
	 * @param instanceName
	 * @throws Exception
	 */
	void assertNotEqual(String grammarName, String instanceName)
			throws Exception;

	/**
	 * Change the name with instance name.
	 * 
	 * @param name
	 * @return
	 * @throws UnsupportedOperationException
	 */
	String updateRef(String name) throws UnsupportedOperationException;

	/**
	 * Check if the given name is one of the existed declarations.
	 * 
	 * @param name
	 * @return
	 */
	boolean containsDeclaration(String name);

	/**
	 * Return the coordinator.
	 * 
	 * @return
	 */
	Coordinator getCoordinator();

	/**
	 * Get the grammar name.
	 * 
	 * @return
	 */
	String getGrammarName();

	/**
	 * Get the instance name.
	 * 
	 * @return
	 */
	String getInstanceName();

	/**
	 * Get the instances.
	 * 
	 * @return
	 */
	Map<String, String> getInstances();

	/**
	 * Get the namespace name.
	 * 
	 * @return
	 */
	String getNamespaceName();

	/**
	 * Get the qualified instance name.
	 * 
	 * @param name
	 * @return
	 */
	String getQualifiedName(String name);

	/**
	 * Check if the grammar is an interface.
	 * 
	 * @param name
	 * @return
	 */
	boolean isAnInstance(String name);

	/**
	 * Check if the grammar is a the first to load.
	 * 
	 * @return
	 */
	boolean isPrimaryGrammar();

	/**
	 * Change the name prepended with the instance name.
	 * 
	 * @param name
	 * @return
	 * @throws UnsupportedOperationException
	 */
	String prefixWithInstanceName(String name)
			throws UnsupportedOperationException;

	/**
	 * Set the coordinator.
	 * 
	 * @param coordinator
	 */
	void setCoordinator(Coordinator coordinator);

	/**
	 * Set the grammar name.
	 * 
	 * @param grammarName
	 */
	void setGrammarName(String grammarName);

	/**
	 * Set the instance name.
	 * 
	 * @param instanceName
	 */
	void setInstanceName(String instanceName);

	/**
	 * Set is the primary grammar.
	 * 
	 * @param isPrimaryGrammar
	 */
	void setIsPrimaryGrammar(boolean isPrimaryGrammar);

	/**
	 * Set the full form namespace name.
	 * 
	 * @param corpusName
	 */
	void setQualifiedNamespaceName(String corpusName);
}
